﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using SMS.Entities;
using SMS.DAL;

namespace SMS.Web.Service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "BranchService" in code, svc and config file together.
    public class BranchService : IBranchService
    {
        public List<Entities.Master.Branch> SearchBranch(string userName, string SearchText, out Entities.SMSException ServiceError)
        {
            try
            {
                ServiceError = null;
                return new SMS.DAL.BranchDA().SearchObject(userName, SearchText);
            }
            catch (Exception ex)
            {
                ServiceError = new Entities.SMSException(ex);
                return null;
            }
        }

        public int SaveBranch(string username, Entities.Master.Branch BranchObject, out SMSException serviceError)
        {
            try
            {
                var retObj = new BranchDA().SaveObject(username, BranchObject);
                serviceError = null;
                return retObj.Branch_ID;
            }
            catch (Exception ex)
            {
                serviceError = new Entities.SMSException(ex);
                return -1;
            }
        }

    }
}
